<?php
/**
 * Field with autocompleter for member of association (exclude special account of association)
 *
 * @package    letsManager
 * @subpackage widget
 * @author     Jerome Fouilloy
 * @version    SVN: $Rev$
 */
class letsWidgetFormMemberSelect extends sfWidgetFormJQueryAutocompleter
{
  /**
   * @see sfWidget
   */
  public function __construct($options = array(), $attributes = array())
  {
    $options['value_callback'] = array($this, 'valueCallback');
    $options['url'] = sfContext::getInstance()->getController()->genUrl('@lets_members_ajax_search');
    $options['config'] = '{ max: 30,width: 260, autoFill: true, minChars: 2 }';
    $attributes['style'] = 'width: 260px';
  //	$options['exclude_me'] = 
    parent::__construct($options, $attributes);
  }

  /**
   * Configures the current widget.
   *
   * @param array $options     An array of options
   * @param array $attributes  An array of default HTML attributes
   *
   * @see sfWidgetFormJQueryAutocompleter
   */
/*  protected function configure($options = array(), $attributes = array())
  {

    parent::configure($options, $attributes);
  }*/
    
   /**
   * Returns the text representation of a foreign key.
   *
   * @param string $value The primary key
   */
  protected function valueCallback($value)
  {
    if($value == '')
      return '';
    return LetsMemberTable::getNameById($value,true);

  }
  
}